﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace MND
{
    class Game
    {
        // Worlds
        public Dictionary<string, Worlds.World> LoadedWorlds = new Dictionary<string, Worlds.World>();

        // UserManager
        private Users.UserManager uManager;
        public Users.UserManager UserManager
        {
            get { return uManager; }
            set { uManager = value; }
        }


        private volatile bool go = false;
        private Thread GameThread;



        public void Start()
        {
            if (GameThread == null)
                GameThread = new Thread(Loop);

            if (!go)
                go = true;

            if (!GameThread.IsAlive)
                GameThread.Start();
        }
        private void Loop()
        {
            while (go)
            {
                // Tick!
                UserManager.Tick();
            }
        }

        public void Stop()
        {
            if (go)
                go = false;
        }
    }
}
